<!DOCTYPE html>
<html>

<head lang="en">
    <title>首页</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/reset.css" rel="stylesheet">
    <link rel="stylesheet" href="/css/index.css" rel="stylesheet">
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css" rel="stylesheet">
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/common.js"></script>



    <script>
        $(function () {
            //处理缓存问题
            $("#ipage").attr("src", "/mine/simpleProfiles.html?" + new Date().getTime());
            //发送请求去查询  获取最近三周的游记推荐数据
            $.get("/travels/commends", {type: 1, pageSize: 3}, function (data) {
                //渲染数据
                $("#travelsCommends").renderValues(data, {
                    getHref: function (item, value) {
                        var url = $(item).data("url");
                        $(item).attr('href', url + value);
                    }
                });
                //默认选择第一页
                $(".carousel-item:first").addClass("active");
            });


			//当点击搜索框的时候清空搜索框
            $("#search").val("");
			//给搜索绑定点击事件
			$("#searchBtn").click(function () {
                //console.log($("#search").val());
                //获取搜索框中的数据
                var keyword=$("#search").val();
                //判断是否有值,有值再进行跳页面搜索
                if(keyword==null||keyword.length==0){
                    //使用提示框进行提示
                    $(document).dialog({
                        titleText:"温馨提示",
                        content:"搜索内容不能为空"
                    });
                }else{
                    //有值就进行跳转页面并将关键字数据带上
                    window.location.href="/search.html?keyword="+keyword
                }
            });

			//发送请求获取热门的日报
            $.get('/dailyPaper/',{stateId:1},function (data) {
                $("#bigger").renderValues(data.list[0], {
                    getHref:getHref
                })
            });

            $.get('/dailyPaper/',{stateId:0},function (data) {
                console.log(data.list);
                $("#smaller").renderValues(data, {
                    getHref:getHref
                })
            });

            $("#12").attr("href","/dailypaper.html");
        });
    </script>
    <style>
        .css{
            width: 200px;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }
    </style>
</head>


<body>
<div class="body">
    <input type="checkbox" id="menu">

    <label for="menu" class="menu">
        <span><i class="fa fa-user fa-fw fa-2x"></i></span>
        <span><i class="fa fa-chevron-left fa-fw fa-2x" style="color: #3E3C3B"></i></span>
    </label>

    <!-- 侧边栏 -->
    <div class="nav">
        <iframe id="ipage" frameborder="0" width="90%"></iframe>
    </div>



    <div class="search-head">
        <div class="row nav-search">
            <div class="col-2"></div>
            <div class="col-8">
                <div class="input-group-sm search">
                    <input id="search" class="form-control" placeholder="搜索旅行攻略、日记和旅游资讯">
                </div>
            </div>
            <!--搜索放大镜按钮-->
            <div class="col-1">
                <i class="fa fa-search" id="searchBtn"
                   style="color:white;font-size:25px;position: absolute;top: 23%;left: 88%">
                </i>
            </div>
        </div>

    </div>

    <div class="container">
        <h6 class="module-title">每周推荐</h6>
        <div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
            <div id="travelsCommends">
                <div class="carousel-inner" render-loop="list">
                    <div class="carousel-item ">
                        <a render-fun="getHref" render-key="list.travelId" data-url="/travelContent.html?id=">
                            <img class="d-block w-100" render-src="list.coverUrl" width="100%" height="200px">
                            <span class="recommend" render-html="list.title"></span></a>
                        <div class="recommend-author"><a href="#">
                            <img class="rounded-circle" style="width: 10%;" render-src="list.authorHeadImgUrl">
                            <span render-html="list.authorName"></span>
                        </a>在&nbsp;
                            <span render-html="list.placeName">广州</span>
                        </div>
                    </div>
                </div>
            </div>
            <a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
                <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                <span class="sr-only"></span>
            </a>
            <a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
                <span class="carousel-control-next-icon" aria-hidden="true"></span>
                <span class="sr-only"></span>
            </a>
        </div>
        <hr>

        <div class="row nav-box">
            <div class="col" style="background-color: #DFE823;" align="center">
                <a href="strategyPage.html"><i class="fa fa-plane fa-fw"></i> 找攻略</a>
            </div>
            <div class="col" style="background-color: #7281D5;" align="center">
                <a href="travelPage.html"><i class="fa fa-book fa-fw"></i> 看游记</a>
            </div>
        </div>

        <div class="row nav-box">
            <div class="col" style="background-color: lightseagreen" align="center">
                <a href="questionAndAnswers.html"><i class="fa fa-question fa-fw"></i>问达人</a>
            </div>
            <div class="col" style="background-color:#ff4f49;" align="center">
                <a href="mall6.html"><i class="fa fa-superpowers fa-fw"></i> 窝窝商城</a>
            </div>
            <div class="col" style="background-color:palevioletred;" align="center">
                <a href="wowomap.html"><i class="fa fa-map fa-fw"></i>百度地图</a>
            </div>
        </div>

        <div class="row dynamic " id="comments">
            <div class="col-1" style="padding: 0px;">
                <img class="rounded" src="/img/topComment.png" style="width: 50px;">
            </div>
            <div class="col">
                <div class="Marquee"  render-loop="list">
                    <div class="d-flex">
                        <a data-url="/userProfiles.html?id=" render-fun="getHref" render-key="list.user.id">
                            <img class="rounded-circle dynamic-head"render-src="list.user.headImgUrl">
                        </a>
                        <a data-url="/mine/strategyComment.html?id=" class="dynamic-detail" render-fun="getHref"
                           render-key="list.id">
                            <span render-html="list.user.nickName"></span> 点评了攻略
                            <p render-html="list.strategy.title">广州攻略</p>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <hr>

    <div class="container">
        <h6 class="module-title">骡窝日报 <a id="12">更多</a></h6>

        <div class="news " id="bigger">
            <a render-fun="getHref" render-key="id" data-url="/dailypaperContent.html?id=">
                    <img width="100%" render-src="coverUrl">
                    <div class="caption">
                        <h5 render-html="title"></h5>
                        <!--<p class="css" render-html="content" style="font-size: 20px"></p>-->
                    </div>
                </a>
        </div>

        <hr>

        <div id="smaller">
            <div style="margin-bottom: 20px" render-loop="list">
                <a render-fun="getHref" render-key="list.id" data-url="/dailypaperContent.html?id=">
                    <div class="row news-detail">
                        <div class="col-5">
                            <img render-src="list.coverUrl">
                        </div>
                        <div class="col-7">
                            <h4 render-html="list.title"> 全球最性感的海滩！</h4>
                            <!--<p>男人女人都为之疯狂。 </p>-->
                        </div>
                    </div>

                    <hr>
                </a>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        //头条点评动态更换
        $.get("/strategyComments", function (data) {
            //console.log(data);
            $("#comments").renderValues(data, {
                getHref: getHref
            });
            showComments();
        })
    })

    function showComments() {
        var Mar = document.getElementsByClassName("Marquee")[0];
        var child_div = Mar.getElementsByTagName("div");
        var picH = 50;//移动高度
        var scrollstep = 3;//移动步幅,越大越快
        var scrolltime = 20;//移动频度(毫秒)越大越慢
        var stoptime = 3000;//间断时间(毫秒)
        var tmpH = 0;
        Mar.innerHTML += Mar.innerHTML;

        function start() {
            if (tmpH < picH) {
                tmpH += scrollstep;
                if (tmpH > picH) tmpH = picH;
                Mar.scrollTop = tmpH;
                setTimeout(start, scrolltime);
            } else {
                tmpH = 0;
                Mar.appendChild(child_div[0]);
                Mar.scrollTop = 0;
                setTimeout(start, stoptime);
            }
        }
        setTimeout(start, stoptime)
    }
</script>
</body>

</html>